package com.beiding.listener;


import com.beiding.dao.OrderDao;
import com.beiding.pojo.order.Order;
import com.beiding.pojo.payload.Payload;
import com.beiding.timeout.bean.DelayTaskListener;
import com.beiding.timeout.bean.TimeShaft;

//给监听器添加两个方法
public abstract class TimeoutListener extends DelayTaskListener<String> {

    OrderDao orderDao;
    TimeShaft<String> timeShaft;

    protected TimeoutListener(OrderDao orderDao, TimeShaft<String> timeShaft, String type) {
        super(type);
        this.orderDao = orderDao;
        this.timeShaft = timeShaft;
    }

    boolean judge(Order order, int... states) {

        if (order == null) {
            return false;
        }

        for (int s : states) {
            if (s == order.getState()) {
                return true;
            }
        }

        return false;

    }


    Payload update(Order order) {
        return Payload.create("order.update").order(order);
    }


}
